<?php
/**
 * AutoLoad use SPL autoload
 * @author François Guégnaud
 *
 */
require_once 'HackInPain/Singleton/Abstract.php';

class HackInPain_AutoLoad_SPL extends HackInPain_Singleton_Abstract {

	static public function AutoLoad() {
		function loadClass($class) {
			$namefile = '/' . preg_replace('/_/', '/', $class) . '.php';
			foreach(explode(PATH_SEPARATOR, get_include_path()) as $path) {
				$file = realpath($path.$namefile);
				if (is_file($file)) {
					require_once $file;
				}
			}
		}
		spl_autoload_register('loadClass', true);
	}
}